;:sys36864
	;.opt oo
	*= $c000
getx	=$b7f1
bank	=56576
vic	=$d000
screen	=648
tmp	=253
clrscr	=$e544
hires	=$a000
getcor	=$b7eb
illquan	=$b248
xcoord	=$14
komma	=$aefd
konf	=1
grcol	=1
dx	.word 0
dy	.word 0
y2	brk
xwert	.word 0
rest	.word 0
xadd	.word 0
yadd	brk
mode	brk
xmerk	brk
lin	brk
ywert	brk
x2	.word 0
patt	brk
patt2	brk
offx	brk
axk	.word 1
rebit	.byt $80,$40,$20,$10,8,4,2,1
dbank	.byt 151,149
dgraf	.byt 27,59
dscre	.byt 4,140
dfind	.byt 23,61
mult	=*
	.word $a000,$a140,$a280,$a3c0
	.word $a500,$a640,$a780,$a8c0
	.word $aa00,$ab40,$ac80,$adc0
	.word $af00,$b040,$b180,$b2c0
	.word $b400,$b540,$b680,$b7c0
	.word $b900,$ba40,$bb80,$bcc0
	.word $be00
gron	jsr getx
	txa
	and #1
	tax
	lda dbank,x
	sta bank
	lda dgraf,x
	sta vic+17
	lda dscre,x
	sta screen
	sta tmp+1
	lda dfind,x
	sta vic+24
	txa
	bne an
	jmp clrscr
an	ldy #0
	sty tmp
	ldx #4
	lda #grcol
fill	sta (tmp),y
	iny
	bne fill
	inc tmp+1
	dex
	bne fill
ill	rts
clr	ldy #0
	tya
	sty tmp
	ldx #>hires
	stx tmp+1
	ldx #32
	bne fill
setpt	jsr komma
	jsr getcor
	stx xmerk
	jsr getx
	stx mode
	ldx xmerk
set	cpx #200
	bcs ill
	lda xcoord+1
	cmp #>320
	bcc ok
	bne ill
	lda xcoord
	cmp #<320
	bcs ill
ok	txa
	lsr
	lsr
	lsr
	asl
	tay
	lda mult+1,y
	sta tmp+1
	txa
	and #7
	clc
	adc mult,y
	sta tmp
	lda xcoord
	and #$f8
	adc tmp
	sta tmp
	lda tmp+1
	adc xcoord+1
	sta tmp+1
	lda xcoord
	and #7
	tax
	lda rebit,x
	ldx #54
	stx konf
	ldy #0
	ldx mode
	beq reset
	bmi invers
	ora (tmp),y
	bne sqd
reset	eor #-1
	and (tmp),y
	jmp sqd
invers	eor (tmp),y
sqd	sta (tmp),y
	inc konf
	rts
line	lda #0
	sta patt2
	sei
	jsr komma
	jsr getcor
	stx ywert
	lda xcoord
	sta xwert
	lda xcoord+1
	sta xwert+1
	jsr komma
	jsr getcor
	stx y2
	lda xcoord
	sta x2
	lda xcoord+1
	sta x2+1
	jsr getx
	stx patt
	jsr getx
	stx mode
	sec
	lda x2
	sbc xwert
	sta dx
	lda x2+1
	sbc xwert+1
	sta dx+1
	bpl line1
	eor #-1
	sta dx+1
	lda dx
	eor #-1
	clc
	adc #1
	sta dx
	bcc noinc1
	inc dx+1
noinc1	lda #-1
	sta xadd
	sta xadd+1
	jmp line2
line1	lda #1
	sta xadd
	lda #0
	sta xadd+1
line2	lda dx+1
	bne line3
	lda dx
	bne line3
	lda #0
	.byt $2c
line3	lda #-1
	sta rest
	sta rest+1
	sec
	lda y2
	sbc ywert
	sta dy
	lda #0
	sbc #0
	sta dy+1
	bpl line5
	eor #-1
	sta dy+1
	lda dy
	eor #-1
	clc
	adc #1
	sta dy
	bcc noinc2
	inc dy+1
noinc2	lda #-1
	.byt $2c
line5	lda #1
	sta yadd
	lda dy+1
	cmp dx+1
	bcc line7
	lda dy
	cmp dx
	bcc line7
	lda #-1
	.byt $2c
line7	lda #1
	sta lin
line8	lda patt
	bne line8a
	dec patt2
	bpl line9
	lda #15
	sta patt2
	bne line8b
line8a	asl
	adc #0
	sta patt
	and #1
	beq line9
line8b	lda xwert
	sta xcoord
	lda xwert+1
	sta xcoord+1
	ldx ywert
	jsr set
line9	lda ywert
	cmp y2
	bne line10
	lda xwert
	cmp x2
	bne line10
	lda xwert+1
	cmp x2+1
	bne line10
	cli
	rts
line10	lda rest+1
	bmi zweig1
	sec
	lda rest
	sbc dx
	sta rest
	lda rest+1
	sbc dx+1
	sta rest+1
	clc
	lda ywert
	adc yadd
	sta ywert
	lda lin
	bmi line8
	bpl line9
zweig1	clc
	lda rest
	adc dy
	sta rest
	lda rest+1
	adc dy+1
	sta rest+1
	clc
	lda xwert
	adc xadd
	sta xwert
	lda xwert+1
	adc xadd+1
	sta xwert+1
	lda lin
	bmi line9
	jmp line8
cruize	jsr komma
	jsr getcor
	stx ywert
	lda xcoord
	sta xwert
	lda xcoord+1
	sta xwert+1
	jsr getx
	stx mode
	lda xwert
	sta xcoord
	lda xwert+1
	sta xcoord+1
	ldx ywert
	jsr set
	ldx ywert
	dex
	jsr set
	ldx ywert
	inx
	jsr set
	inc xcoord
	bne noc
	inc xcoord+1
noc	ldx ywert
	jsr set
	lda xcoord
	sec
	sbc #2
	sta xcoord
	lda xcoord+1
	sbc #0
	sta xcoord+1
	ldx ywert
	jmp set
